import React, { useState,useEffect } from "react";



function App() {
  const [song,setSong] = useState([
    {id:'001',name:'中国话'},
    {id:'002',name:'美人鱼'},
    {id:'003',name:'喜欢你'},
    {id:'004',name:'星星点灯'},
  ])
  const setSonghandle = ()=>{
    setSong([...song,{id:Date.now(),name:'xxxx'}])
  }
  useEffect(()=>{
    console.log('歌曲添加成功');
  },[song])
 return(
  <div>
    <button onClick = {setSonghandle}>添加歌曲</button>
    <ul>
      {song.map(item=>{
       return <li key={item.id}>{item.name}</li>
      })}
    </ul>
  </div>
 )
}

export default App;
